function binarySearch<T>(arr: T[], target: T): number {
  if (!arr.length) return -1;

  let left = 0;
  let right = arr.length - 1;

  while (left <= right) {
    const center = Math.floor((left + right) / 2);
    console.log(center, left, right, right + left);

    const newTarget = arr[center];
    if (newTarget === target) {
      return center;
    } else if (newTarget < target) {
      left = center + 1;
    } else {
      right = center - 1;
    }
  }

  return -1;
}

console.log(binarySearch<string>(["1", "2", "3", "4", "5", "6"], "6"));
console.log(performance.now());

export {};
